# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=imbalanced-learn
pkgbase=mingw-w64-python3-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.5.0
pkgrel=1
pkgdesc="A Python Package to Tackle the Curse of Imbalanced Datasets in Machine Learning (mingw-w64)"
arch=('any')
url='https://github.com/scikit-learn-contrib/imbalanced-learn'
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-numpy"
             "${MINGW_PACKAGE_PREFIX}-python3-scikit-learn"
             "${MINGW_PACKAGE_PREFIX}-cython"
             )
source=("${_realname}-${pkgver}.tar.gz::https://github.com/scikit-learn-contrib//${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('3bad0144b0ecc078d29026ce785f3160d00eba1ffdcb51ffcff56e840f8c68fb')

prepare() {
  cd "${srcdir}"
  rm -rf python3-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python3-build-${CARCH}"
}

build() {
  msg "Python 3 build for ${CARCH}"
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python3 setup.py build
}

package() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3"
            "${MINGW_PACKAGE_PREFIX}-python3-numpy"
            "${MINGW_PACKAGE_PREFIX}-python3-scipy"
            )

  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -D LICENSE "$pkgdir"/${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}
